from google.appengine.api import mail
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import login_required

import wsgiref.handlers

from google.appengine.ext import webapp

class InviteFriendHandler(webapp.RequestHandler):
  @login_required
  def post(self):
    to_addr = self.request.get("friend_email")
    if not mail.is_email_valid(to_addr):
      # Return an error message...
      pass
      
    message = mail.EmailMessage()
    message.sender = users.get_current_user().email()
    message.to = to_addr
    message.Subject="hi"
    message.body = """
    I've invited you to Example.com!

    To accept this invitation, click the following link,
    or copy and paste the URL into your browser's address
    bar:

    %s
    """ % generate_invite_link(to_addr)

    message.send()
  def get(self):
   mail.send_mail(sender="buckler.liu@gmail.com",
              to="aliufei@126.com",
              subject="Your account has been approved",
              body="""           The example.com Team            """)
      
    
    
def main():
  application = webapp.WSGIApplication(
                                       [('/mail', InviteFriendHandler)],
                                       debug=True)
  wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
  main()    


###  